import 'package:get/get.dart';
import 'package:pet/app/storage/token.dart';

class Environment {
  final String wss;
  final String host;

  const Environment({required this.wss, required this.host});
}

const devEnv = Environment(
  wss: "wss://ws.wsr-business.com",
  host: "https://web.wsr-business.com",
);

const prodEnv =
    Environment(wss: "wss://ws.petgoods.vip", host: "https://web.petgoods.vip");

Environment config() {
  bool inProduction = bool.fromEnvironment("dart.vm.product");
  if (!inProduction) {
    TokenStorage tokenStorage = Get.find<TokenStorage>();
    inProduction = tokenStorage.getEnv();
  }
  return inProduction ? prodEnv : devEnv;
}

setEnv() {
  TokenStorage tokenStorage = Get.find<TokenStorage>();

  tokenStorage.setEnv(!tokenStorage.getEnv());
}
